/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:何人亮
 * Date:2024-12-02
 * 22:43
 */
public class Test {
    public static void main(String[] args) {

    }
    public class Solution {
        public boolean hasCycle(ListNode head) {

            ListNode slow=head;
            ListNode fast=head;
            boolean b=false;
            while(fast!=null&&fast.next!=null){

                slow=slow.next;
                fast=fast.next.next;
                if(slow==fast){
                    b=true;
                    break;
                }
            }
            return b;
        }
    }
}
